﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Xml;

namespace FinPlusCommon
{
    public interface IFunction : IEnumerable<IItem>, INotifyCollectionChanged, INotifyPropertyChanged
    {
        object this[string name, string user = null] { get; set; }
        int Id { get; set; }
        string LinkedId { get; set; }
        string Name { get; set; }
        string Error { get; set; }
        bool IsClosed { get; set; }
        bool IsDirty { get; set; }
        IList<string> Parents { get; set; }
        IList<string> Children { get; set; }
        EventHandler<ItemEventArgs> ItemUpdate { get; set; }
        object Object { get; set; }
        Type Type { get; set; }
        string Invoke { get; set; }
        string ServiceKey { get; set; }
        void ItemsUpdate(IFunction func);

        void Refresh();

        IFunction Clone(int id = -1);

        IItem Add(string name, int index, int id, object value, string user, DateTime timeStamp);

        IItem Add(string name, object value, string user = "", int id = -1);

        IItem Get<T>(string name, T defaultValue, PropertyChangedEventHandler changeEventHander = null);

        IItem Get(string name, PropertyChangedEventHandler changeEventHander = null);

        bool TryAdd(IItem item, bool withHistory = false, bool newKey = false);

        void Add(IDictionary<string, string> items);

        void Append(IFunction func);

        void Append(IFunctions funcs);

        void Remove(IItem item);

        object Value(string name, object defaultValue = null);

        string SortKey(string[] sortOrders);

        bool IsEqual(IFunction func);

        bool IsMatch(string where);

        string ToString();

        string ToString(string[] DisplayFields);

        object[,] ToArray();

        IList<IItem> ToList(string match, bool isValMatch = true);

        object[] ToParamArray(IList<string> exclude = null);

        void ToXmlDoc(XmlDocument xmlDoc, string node);

        string Replace(string value);
    }
}
